<?php

class CmsFramework {
	public static function IncludeCss() {
		echo '<link type="text/css" href="css/reset-fonts-grids.css" rel="stylesheet" />'."\n";
		echo '<link type="text/css" href="css/cms-generic.css" rel="stylesheet" />'."\n";
		echo '<link type="text/css" href="css/laughing.css" rel="stylesheet" />'."\n";
		echo '<link type="text/css" href="css/start/jquery-ui-1.7.1.custom.css" rel="stylesheet" />'."\n";

        //table grid lib
		echo '<link type="text/css" href="css/ui.jqgrid.css" rel="stylesheet" />';

        //autocomplete lib
		echo '<link type="text/css" href="css/jquery.autocomplete.css" rel="stylesheet" />'."\n";
		echo '<link type="text/css" href="css/thickbox.css" rel="stylesheet" />'."\n";


        //ddcombo
		//echo '<link type="text/css" href="js/combobox/asset/jquery.ddcombo.css" rel="stylesheet" />'."\n";


		echo '<link type="text/css" href="css/pms.css" rel="stylesheet" />'."\n";
	}

	public static function IncludeJs() {

	//	echo '<script src="js/tvb-utils.js" type="text/javascript"></script>'."\n";

		echo '<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/jquery.namespace.js" type="text/javascript"></script>'."\n";
		//echo '<script src="js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>'."\n";\
		//echo '<script src="js/json2.js" type="text/javascript"></script>'."\n";

	//	echo '<script src="js/jquery-laughing.js" type="text/javascript"></script>'."\n";
		//echo '<script src="js/jquery.maskedinput-1.2.2.min.js" type="text/javascript"></script>'."\n";
        //RED
		//echo '<script src="red/swfobject.js" type="text/javascript"></script>'."\n";
		//echo '<script src="red/red.js" type="text/javascript"></script>'."\n";
        //table grid lib
		/*echo '<script src="js/grid/jquery.layout.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/grid/jqModal.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/grid/jquery.jqGrid.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/grid/jquery.tablednd.js" type="text/javascript"></script>'."\n";

        //autocomplete lib

		echo '<script src="js/jquery.bgiframe.min.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/jquery.ajaxQueue.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/thickbox-compressed.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/jquery.autocomplete.js" type="text/javascript"></script>'."\n";/*

        //Video player
		//echo '<script src="js/swfobject.js"></script>'."\n";


        //ddcombo
        /*
		echo '<script src="js/combobox/dependency/jquery.ready.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/dependency/jquery.flydom-3.1.1.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/dependency/autocomplete/jquery.bgiframe.min.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/dependency/autocomplete/jquery.dimensions.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/dependency/autocomplete/jquery.ajaxQueue.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/dependency/autocomplete/thickbox-compressed.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/combobox/js/jquery.ddcombo.js" type="text/javascript"></script>'."\n";
        */

        //generic
		echo '<script src="js/cms-generic.js" type="text/javascript"></script>'."\n";

        //pms
		echo '<script src="js/pms-init.js" type="text/javascript"></script>'."\n";

	}

/*	public static function IncludeValidator() {
		echo '<script src="js/jquery.maskedinput-1.2.2.min.js" type="text/javascript"></script>'."\n";
		echo '<script src="js/jquery.validate.js" type="text/javascript"></script>'."\n";
		echo '<script type="text/javascript">'."\n"; 
		echo <<< REGEXP
		$.validator.addMethod('regexp', function(value, element, params) {
			var regex = new RegExp(params.substring(1, params.length-1));
			var result = this.optional(element) || regex.test(value);
			return result;	
		}, "Invalid format");

REGEXP;
		echo '</script>'."\n";
	}
*/
	public static function ValidateForm($validation_rules) {
		$valid = true;
		foreach ($validation_rules as $name => $rules) {
			foreach ($rules as $rule_name => $params) {
				$rule_name = strtr($rule_name, array(
					'min' => 'minvalue',
					'max' => 'maxvalue'
				));
				$valid |= call_user_func("Validate::$rule_name", $params, $_REQUEST[$name]);
			}
		}
		return $valid;
	}

	public static function LoadingMask() {
		echo '<div id="loading_mask" class="ui-widget-overlay">Loading ...</div>';
	}

	public static function InitComplete() {
		echo '<script type="text/javascript">'."\n"; 
		echo '$("#loading_mask").remove();';
		echo '</script>'."\n";
	}
}

?>
